#include<iostream>
using namespace std;
#include<vector>
class Solution {
public:
    vector<int> occurrencesOfElement(vector<int>& nums, vector<int>& queries, int x) {
        int arr[100001] = { 0 };
        int now = 1, n = nums.size();
        for (int i = 0; i < n; ++i)
            if (nums[i] == x)
                arr[now++] = i;
        vector<int> ans;
        for (auto& e : queries) {
            if (e < now)
                ans.push_back(arr[e]);
            else
                ans.push_back(-1);
        }
        return ans;
    }
};